class Solution {
    public int[] vowelStrings(String[] words, int[][] queries) {
        // a e i o u 前缀和记录元音字符数
        boolean[] yuan = new boolean[26];
        yuan['a' - 'a'] = yuan['e' - 'a'] = yuan['i' - 'a'] = yuan['o' - 'a'] = yuan['u' - 'a'] = true;
        int n = words.length;
        int[] pre = new int[n + 1];
        int tmp;
        for (int i = 0; i < n; i++) {
            pre[i + 1] = pre[i];
            if (yuan[words[i].charAt(0) - 'a'] && yuan[words[i].charAt(words[i].length() - 1) - 'a'])
                pre[i + 1] += 1;
        }
        // for(int x:pre)System.out.println(x);
        int m = queries.length;
        int[] ans = new int[m];
        for (int i = 0; i < m; i++) {
            ans[i] = pre[queries[i][1] + 1] - pre[queries[i][0]];
        }
        return ans;
    }
}